package com.qf.pkg.controller;

import com.qf.core.dto.PageDto;
import com.qf.core.vo.PageResult;
import com.qf.core.vo.R;
import com.qf.pkg.entity.Package;
import com.qf.pkg.service.PackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 租户套餐表 前端控制器
 * </p>
 *
 * @author zhu
 * @since 2023-10-27
 */
@RestController
@RequestMapping("/package")
@CrossOrigin
public class PackageController {


    @Autowired
    private PackageService packageService;

    @PostMapping("add")
    public R add(@RequestBody Package pck){
        return packageService.add(pck);
    }

    /**
     * 套餐分页接口
     * @param pageDto
     * @return
     */
    @PostMapping("page")
    public PageResult<Package> page(@RequestBody PageDto<Package> pageDto){
        PageResult<Package> packagePageResult = packageService.selectPage(pageDto);
        return packagePageResult;
    }

    @PostMapping("update")
    public R update(@RequestBody Package pck){
        return R.ok(packageService.updateById(pck));
    }

    @PostMapping("delete")
    public R delete(@RequestBody Package pck){
        return R.ok(packageService.removeById(pck.getId()));
    }
}
